home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Modem.h
-
- Contains: Definitions for the USB Modem Driver
-
- Version: xxx put version here xxx
-
-
-
- Copyright: © 1995-1998 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #ifndef _MODEM_
- #define _MODEM_
-
- #include <Serial.h>
- #include <USB.h>
-
- #include "SerialShim.h"
-
- // Debug stuff
-
- #define DebugOn 0 // This is the master switch (On > 0)
- #define LogOn 0 // On > 0 (DebugOn must also be on)
- #define FullTrace 0 // On > 0 Be careful with this as it traces everything (DebugOn must also be on)
-
- #if (DebugOn > 0)
- #define DebugMessage(s) DebugStr(s)
- #else
- #define DebugMessage(s)
- #endif
-
- #if ((DebugOn > 0) && (LogOn > 0))
- #define LogData(x, y, z) USBLogData(x, y, z)
- #else
- #define LogData(x, y, z)
- #endif
-
- #if (DebugOn > 0)
- #define TraceMessage(x, s) {if (FullTrace > 0) USBExpertStatus(0, s, 0); else if (x) USBExpertStatus(0, s, 0);}
- #else
- #define TraceMessage(x, s)
- #endif
-
- #if (DebugOn > 0)
- #define StatusMessage(a, s, c) USBExpertStatus(a, s, c)
- #else
- #define StatusMessage(a, s, c)
- #endif
-
- #if (DebugOn > 0)
- #define noteError(s) sp->errorString = s;
- #else
- #define noteError(s)
- #endif
-
- // Change these for other modems etc.
-
- #define kUSBVendor 0x0000 // ABC Modem company
- #define kUSBProduct 0x0000 // A very fast modem
- #define kModemName "\pUSB Modem" // Name registry name
- // The following three names will be made unique
- // by the shim if they are not
- #define kCRMName "\pUSB" // CRM name
- #define kDRVRInName "\p.UIn" // .In driver name
- #define kDRVROutName "\p.UOut" // .Out driver name
-
- // USB stuff
-
- #define k5DataBits 5
- #define k6DataBits 6
- #define k7DataBits 7
- #define k8DataBits 8
-
- #define k1StopBit 0
- #define k15StopBits 1
- #define k2StopBits 2
-
- #define kNoParity 0
- #define kOddParity 1
- #define kEvenParity 2
- #define kMark 3
- #define kSpace 4
-
- #define kDTROff 0
- #define kRTSOff 0
- #define kDTROn 1
- #define kRTSOn 2
-
- #define kBreakOn 0xFFFF
- #define kBreakOff 0
-
- #define kUSBDCD 0x01
- #define kUSBDSR 0x02
- #define kUSBBreakDetect 0x04
- #define kUSBRingSignal 0x08
- #define kUSBFramingErr 0x10
- #define kUSBParityErr 0x20
- #define kUSBHwOverRunErr 0x40
-
- typedef struct{
- UInt16 DTERate1;
- UInt16 DTERate2;
- UInt8 CharFormat;
- UInt8 ParityType;
- UInt8 DataBits;
- } LineParms;
-
- enum{
- kSendEncapsulatedCommand = 0,
- kGetEncapsulatedResponse = 1,
- kSetCommFeature = 2,
- kGetCommFeature = 3,
- kClearCommFeature = 4,
- kSetLineCoding = 0x20,
- kGetLineCoding = 0x21,
- kSetControlLineState = 0x22,
- kSendBreak = 0x23,
- };
-
- enum{
- kResponseAvailable = 1,
- kSerialState = 0x20,
- };
-
- enum
- {
- kBuiltInBufferSize = 1024,
- kMaxBaudRate = 115200,
- };
-
- // Global data structure
-
- typedef struct ShimSerialGlobals
- {
- // input buffers
- UInt8 builtInBuffer[kBuiltInBufferSize]; // default input buffer
- UInt8 *inBufPtr; // pointer to current input buffer
- UInt16 inBufLen; // length of said buffer
- UInt16 inBufStartIndex; // circular queue indexes
- UInt16 inBufEndIndex;
-
- // serial driver state
-
- UInt8 xOnOffChar; // an xon or xoff char to be sent
- UInt8 lenParStop; // length, parity, stop bits
- UInt8 peChar; // parity error replacement character
- UInt8 peAltChar; // parity error alternate replacement character
- UInt32 baudRate; // actual baud rate value i.e. 19200
- SerShk serShk; // handshake record (see inside mac, vol ii, serial drivers
- SerStaRec serStat; // serial status record (see inside mac, vol ii, serial drivers)
-
- // miscellaneous
-
- ParmBlkPtr pbIn; // current prime read request
- ParmBlkPtr pbOut; // current prime write request
- ShimRefNum ShimRef; // save the shim's reference number
- Boolean openSession; // only allow one open session
- CFragConnectionID ConnID; // connection to the shim
-
- // Install and remove CFM routines
-
- OSErr (*ShimInstall) (SerialShimInterface IntBlk, ShimRefNum *ref);
- OSErr (*ShimRemove) (ShimRefNum ref, Boolean forced);
- void (*ShimComplete) (ShimRefNum ref, IOParam *pb);
-
- } ShimSerialGlobals;
-
- extern ShimSerialGlobals *gGlobals;
-
- #endif
-